<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    // 2, 字母数字组合验证码（四位） (如: 4YT8) (数字,大写字母随机)

    var str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var str2="";
    for(i=0;i<4;i++){
        var num=parseInt(Math.random()*(str.length+1));
        str2+=str[num];
    }
    console.log(str2);
    </script>
</body>
</html>